<?php

namespace App\Providers;

use App\Models\Admin\AdminUserRole;
use App\Models\Admin\Carousel;
use App\Models\Admin\Video;
use App\Models\Admin\Weibo;
use App\Models\Home\Comment;
use App\Models\Home\Link;
use App\Models\Home\Photo;
use App\Models\Home\Topic;
use App\Models\Home\User;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //获取视频  共享视图
        $videos=Video::all();
        view()->share('videos', $videos);
        //获取友情链接  共享视图
        $links = Link::all();
        view()->share('links', $links);
        //获取轮播图片  共享视图
        $carousels = Carousel::all();
        $firstimg = Carousel::first();
        //获取热门话题  共享视图
        $hot_topics = Topic::orderBy('weibo_num', 'desc')->limit(5)->get();
        view()->share('hot_topics', $hot_topics);
        view()->share('carousels', $carousels);
        view()->share('firstimg', $firstimg);


    }

    public function register()
    {
        if ($this->app->environment() !== 'production') {
            $this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
        }
    }
}
